import 'package:bruno/bruno.dart';
import 'package:flutter/material.dart';

import 'package:get/get.dart';

import '../../../../../app/routes/app_pages.dart';
import '../../../../../assets/const.dart';
import '../controllers/login_controller.dart';

class LoginView extends GetView<LoginController> {
  const LoginView({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        resizeToAvoidBottomInset: false,
        body: Padding(
          padding: const EdgeInsets.all(16.0),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              // 图标
              Image.asset(
                ImageConst.ICON,
                width: MediaQuery.of(context).size.width * 0.4, // 响应式宽度
                height: MediaQuery.of(context).size.width * 0.4,
              ),
              SizedBox(height: 20),
              // 账号输入框
              TextField(
                controller: controller.accountController,
                decoration: InputDecoration(
                  labelText: '账号',
                  border: OutlineInputBorder(),
                ),
              ),
              SizedBox(height: 10),
              // 密码输入框
              TextField(
                controller: controller.passwordController,
                obscureText: true,
                decoration: InputDecoration(
                  labelText: '密码',
                  border: OutlineInputBorder(),
                ),
              ),
              SizedBox(height: 10),
              // 隐私协议
              Row(
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  Checkbox(
                    value: false,
                    onChanged: (bool? value) {},
                  ),
                  Text('我同意隐私协议'),
                ],
              ),
              SizedBox(height: 10),
              // 忘记密码

              SizedBox(height: 10),
              // 登录按钮
              BrnBigMainButton(
                title: "登录",
                onTap: () {
                  controller.login();
                },
              ),
              SizedBox(height: 10),
              // 注册按钮
// 底部按钮改为垂直布局
              Column(
                children: [
                  TextButton(
                    child: Text('还没有账号？立即注册',
                        style: TextStyle(color: Colors.blue)),
                    onPressed: () => Get.toNamed(Routes.REGISTER),
                  ),
                  TextButton(
                    child: Text('忘记密码', style: TextStyle(color: Colors.grey)),
                    onPressed: () => Get.toNamed(Routes.RESET_PASSWORD),
                  )
                ],
              )
            ],
          ),
        ));
  }
}
